Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pct calculated fields for Pod and container CPU and memory usages #6158

Merged
merged 3 commits into from
Jan 28, 2018

Conversation

exekias
Copy link
Contributor

@exekias exekias commented Jan 24, 2018

This PR adds the following set of calculated metrics for Pods and containers:

  • kubernetes.container.cpu.usage.node.pct
  • kubernetes.container.cpu.usage.limit.pct
  • kubernetes.container.memory.usage.node.pct
  • kubernetes.container.memory.usage.limit.pct
  • kubernetes.pod.cpu.usage.nanocores
  • kubernetes.pod.cpu.usage.node.pct
  • kubernetes.pod.cpu.usage.limit.pct
  • kubernetes.pod.memory.usage.bytes
  • kubernetes.pod.memory.usage.node.pct
  • kubernetes.pod.memory.usage.limit.pct

As the source of data to calculate these values comes from different places (kubelet & kube-state-metrics) I added a mechanism to share some performance metrics through an in-memory cache. For that reason, these new metrics will only be available when state_* metricsets are enabled.

After talking with @simianhacker, I think this:
closes #6125
closes #6124

Please @simianhacker have a look and let me know if you need anything else

@ruflin
Copy link
Contributor

ruflin commented Jan 25, 2018

@exekias Tests somehow fail on darwin. Probably need to skip it.

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This PR also needs a CHANELOG.

// PerfMetrics stores known metrics from Kubernetes nodes and containers
var PerfMetrics *PerfMetricsCache

const defaultTimeout = 120 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little tricky cause it's a global cache. I used a somehow safe value, I don't think someone needs to worry about it, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it until it breaks :-)

)

// PerfMetrics stores known metrics from Kubernetes nodes and containers
var PerfMetrics *PerfMetricsCache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about init it directly here
var PerfMetrics = NewPerfMetricsCache()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, pushed the change, thanks!

@exekias
Copy link
Contributor Author

exekias commented Jan 26, 2018

Thanks for the reviews! @ruflin this one should be ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants